<?php

namespace App\Providers;

use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;
use Darabonba\OpenApi\Models\Config;
use Illuminate\Support\ServiceProvider;

class AliSmsProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('sms', function () {
            $accessKeyId = config('sms.access_key_id');
            $accessKeySecret = config('sms.access_secret');

            $config = new Config([
                "accessKeyId" => $accessKeyId,
                "accessKeySecret" => $accessKeySecret
            ]);

            // 访问的域名
            $config->endpoint = "dysmsapi.aliyuncs.com";
            return new Dysmsapi($config);
        });
    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}
